package net.oschina.dajiangnan.wx.process.msg;

import net.oschina.dajiangnan.wx.constants.Custom;
import net.oschina.dajiangnan.wx.process.msg.xmlbean.ReceiveEvent;
import net.oschina.dajiangnan.wx.process.msg.xmlbean.SendText;
import net.oschina.dajiangnan.wx.process.msg.xmlbean.XmlBean;


public class EventSubscribe {

    public XmlBean process(ReceiveEvent receiveEvent){
        
        String openid = receiveEvent.getFromUserName();
        
        Custom.wx.subscribe(openid);
        
        String welcome_content = Custom.wx.sendTextFromSubscribe(openid);
        
        if(welcome_content != null){
            SendText sendText = new SendText();
            sendText.setMsgType("text");
            sendText.setCreateTime(receiveEvent.getCreateTime());
            sendText.setFromUserName(receiveEvent.getToUserName());
            sendText.setToUserName(receiveEvent.getFromUserName());
            sendText.setContent(welcome_content);
            return sendText;
        }
        return null;
    }
}
